use std::io;
use rand::Rng;
use std::cmp::Ordering;

fn main() {
    // println!("Hello, world!");
    println!("猜数字游戏！");
    let secret_number = rand::thread_rng().gen_range(1..101);
    // println!("神秘数字是：{}",secret_number);
    let mut guess = String::new();
    print!("请输入你猜的数字：");
    io::stdin().read_line(&mut guess).expect("无法读取行");

    let guess:i32 = guess.trim().parse().expect("请输入一个数字!");

    match guess.cmp(&secret_number) {
        Ordering::Less => println!("太小了"),
        Ordering::Greater => println!("太大了"),
        Ordering::Equal => println!("猜对了"),
    }


}
